package com.weme.common.socket.base

import org.java_websocket.client.WebSocketClient
import java.nio.ByteBuffer

/**
 * 发送消息和接受消息coder Adapter的生产类
 *
 * @author
 */
interface CoderFactory {

    fun getDecoder(client: WebSocketClient?): DecoderAdapter?

    fun getEncoder(client: WebSocketClient?): EncoderAdapter?
}

interface DecoderAdapter {
    fun decode(client: WebSocketClient?, inBuff: ByteBuffer?, output: DecoderCoderOutput)
}

interface EncoderAdapter {
    fun encode(client: WebSocketClient?, cmdId: Int, seq: Long, msg: Any?, output: EncoderCoderOutput)
}

interface DecoderCoderOutput {
    fun write(msg: Any)
}

interface EncoderCoderOutput {
    fun write(msg: ByteBuffer)
}